package com.zhangxin.aiInterview.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * Spring容器上下文,用于获取bean
 */
@Component
public class SpringContextUtil {
    private static ApplicationContext context;

    @Autowired
    public void setApplicationContext(ApplicationContext ctx) {
        context = ctx;
    }

    public static <T> T getBean(Class<T> beanClass) {
        return context.getBean(beanClass);
    }
}